//
//  BaseViewController.swift
//  LCYWeiBo
//
//  Created by 李长友 on 16/8/31.
//  Copyright © 2016年 app. All rights reserved.
//

import UIKit

class BaseViewController: UITableViewController {
    
    var isLogin = UserViewModel.shareInstance.isLogin
    
    /// 访客视图
    lazy var visitorView = NSBundle.mainBundle().loadNibNamed("VisitorView", owner: nil, options: nil).first as! VisitorView
    
    override func loadView() {

        isLogin ? super.loadView() : setupVisitorView()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

extension BaseViewController {
    
    private func setupVisitorView() {
        
        visitorView.loginButton.addTarget(self, action: #selector(BaseViewController.loginButtonClick), forControlEvents: .TouchUpInside)
        view = visitorView
        
    }
}

extension BaseViewController {
    
    @objc private func loginButtonClick() {
        
        let vc = LoginWebViewController()
        presentViewController(UINavigationController(rootViewController: vc), animated: false, completion: nil)
    }
}














